﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Meqs.Entity;
using Meqs.Logic;
using Meqs.Logic.Interface;

public partial class Custom_SchoolYearClasses : System.Web.UI.UserControl
{
    protected IList<TermInfo> terms = new List<TermInfo>();
    protected IList<VClasssInfo> vclasses = new List<VClasssInfo>();
    protected IList<ShowClasssinfo> showlasses = new List<ShowClasssinfo>();
    private bool _isAll = true;
    public bool IsAll
    {
        get { return _isAll; }
        set { _isAll = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SchoolInfo si = SchoolCommon.Sch_SchoolInfo;
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", si.SchoolMark);
            //ht.Add("SchoolYear", si.SchoolYear);
            //ht.Add("Term", si.SchoolTerm);
            terms = Container<ITermInfoLogic>.Instance.FindAll(ht);
            ht = new Hashtable();
            ht.Add("SchoolMark", si.SchoolMark);
            //<isNotNull prepend="and" property="Grade">Grade = #Grade# </isNotNull>
            if(!IsAll)
                ht.Add("Grade", 9);
            vclasses = Container<ITermInfoLogic>.Instance.FindYearClasses(ht);
            int schoolyear = 0;
            ShowClasssinfo sci = null;
            foreach (VClasssInfo vc in vclasses)
            {
                if (schoolyear != vc.SchoolYear)
                {
                    schoolyear = vc.SchoolYear;
                    sci = new ShowClasssinfo();
                    showlasses.Add(sci);
                }
                if (sci != null)
                {
                    sci.year = vc.SchoolYear;
                    sci.classes.Add(vc);
                }
            }
        }
    }
}
public class ShowClasssinfo
{
    public int year = 0;
    public List<VClasssInfo> classes = new List<VClasssInfo>();
}